<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <jsp:include page="/resources/inc/pageHead.jsp"/>
    <link href="${basePath}/resources/zheng-admin/plugins/zTree_v3/css/demo.css" rel="stylesheet"/>
    <link href="${basePath}/resources/zheng-admin/plugins/zTree_v3/css/metroStyle/metroStyle.css" rel="stylesheet"/>
</head>
<body>
<form class="layui-form layui-form-pane" id="_form">
    <input type="hidden" value="" name="fileIds">
    <c:forEach items="${roleFiles}" var="roleFile" varStatus="status">
        <div class="layui-form-item">
            <label class="layui-form-label">${roleFile.title}</label>
            <div class="layui-input-block">
                <c:forEach items="${filePermissions}" var="permission" varStatus="permissionStatus">
                    <input type="radio" name="${roleFile.roleId}" title="${permission.value}"
                           value="${permission.key}"
                    <c:if test="${permission.key == roleFile.permission}">
                           checked="checked"
                    </c:if>
                    >
                </c:forEach>
            </div>
        </div>
    </c:forEach>
    <div class="layui-form-item">
        <label class="layui-form-label">作用于下级</label>
        <div class="layui-input-block">
            <input type="checkbox" name="effect" id="effect" lay-skin="switch" lay-text="是|否">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block" style="float: right">
            <button class="layui-btn" lay-submit="" lay-filter="sub" type="button">立即提交</button>
        </div>
    </div>
</form>
</body>
<jsp:include page="/resources/inc/pageFooter.jsp"/>
<script>
    var roleFiles = ${roleFiles};
    var fileIds = "${fileIds}";
    $(function () {
        FormCommon.initForm({
            url: "${basePath}/manage/oss/file/system/filePermission",
            subContentType: "json",
            editData: function (data) {
                $(roleFiles).each(function (index, roleFile) {
                    roleFile.permission = $("input[name=" + roleFile.roleId + "]:checked").val();
                });
                var effect = false;
                if (data.effect == "on") {
                    effect = true;
                }
                return {roleFiles: roleFiles, effect: effect};
            }
        });
    });
</script>
</html>
